home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 101-125 / disk_108 / tek / init.c < prev    next >
C/C++ Source or Header  |  1992-05-06  |  19KB  |  592 lines

  1. /***************************************************************
  2.  * vt100 - terminal emulator - initialization
  3.  *
  4.  *    v2.65        NG  - added tek4014 emulation
  5.  *    v2.6 870227 DBW - bug fixes for all the stuff in v2.5
  6.  *    v2.5 870214 DBW - more additions (see readme file)
  7.  *    v2.4 861214 DBW - lots of fixes/additions (see readme file)
  8.  *    v2.3 861101 DBW - minor bug fixes
  9.  *    v2.2 861012 DBW - more of the same
  10.  *    v2.1 860915 DBW - new features (see README)
  11.  *         860901 ACS    - Added Parity and Word Length and support code
  12.  *         860823 DBW - Integrated and rewrote lots of code
  13.  *    v2.0 860809 DBW - Major rewrite
  14.  *    v1.1 860720 DBW    - Switches, 80 cols, colors, bug fixes
  15.  *    v1.0 860712 DBW    - First version released
  16.  *
  17.  ***************************************************************/
  18.  
  19. #include "vt100.h"
  20.  
  21. char line[256];
  22. static char cmds[] = "<>GRSBLHX+-I7.DWKCZ";    /* changed a bit for tek    */
  23.  
  24. char *InitDefaults(argc,argv)
  25. int    argc;
  26. char    **argv;
  27.     {
  28.     FILE    *fd;
  29.     char    *p;
  30.     int        l;
  31.  
  32.     doing_init = 1;    /* make sure we only allow INIT script commands */
  33.     if (((argc > 1) && (fd=fopen(argv[1],"r")) != 0) ||
  34.     (fd=fopen("vt100.init","r")) != 0 ||
  35.     (fd=fopen("s:vt100.init","r")) != 0) {
  36.     while (fgets(line,256,fd) != 0) {
  37.         line[strlen(line)-1] = '\000';
  38.         p = next_wrd(&line[0],&l);
  39.         if (*p) {
  40.         *p |= ' ';
  41.         if (p[1]) p[1] |= ' ';
  42.         if (*p == '#') continue;
  43.         if (*p == 'e' && p[1] == 'x') break;
  44.         exe_cmd(p,l);
  45.         }
  46.         }
  47.     fclose(fd);
  48.     }
  49.     doing_init = 0;
  50.  
  51.     /* Now set up all the screen info as necessary */
  52.     if (p_interlace == 0) {
  53.     if (p_lines > 24) p_lines = 24;
  54.     MINY = 14;
  55.     NewWindow.Height    = (long)((p_lines*8)+8);
  56.     }
  57.     else {
  58.     if (p_lines > 48) p_lines = 48;
  59.     MINY = 16;
  60.     NewScreen.ViewModes |= LACE;
  61.     NewWindow.Height    = (long)((p_lines*8)+10);
  62.     }
  63.     NewWindow.MinHeight = NewWindow.Height;
  64.     NewWindow.MaxHeight = NewWindow.Height;
  65.     NewWindow.TopEdge   = 0L;
  66.     MAXY = ((p_lines-1)*8) + MINY;
  67.     top  = MINY;
  68.     bot     = MAXY;
  69.     savx = MINX;
  70.     savy = MINY;
  71.     if (p_screen == 1) {
  72.     if (p_depth > 2) p_depth = 2;
  73.     if (p_depth < 1) p_depth = 1;
  74.     NewScreen.Depth        = (long)p_depth;
  75.     NewScreen.Height    = (long)((p_lines*8)+16);
  76.     if (p_interlace == 1)
  77.         NewScreen.TopEdge   = (long)(400 - NewScreen.Height);
  78.     else
  79.         NewScreen.TopEdge   = (long)(208 - NewScreen.Height);
  80.     }
  81.     else {
  82.     p_depth            = 2L;
  83.     NewWindow.TopEdge    = 0L;
  84.     NewWindow.Screen    = NULL;
  85.     NewWindow.Type        = WBENCHSCREEN;
  86.     }
  87.     /* see if we exit with a startup script */
  88.     if (*p == 'e') {
  89.     p = next_wrd(p+l+1,&l);
  90.     if (*p) return(p);
  91.     }
  92.     return(NULL);
  93.     }
  94.  
  95. void InitDevs()
  96. {
  97. USHORT    colors[4];
  98. int    i;
  99. BYTE    *b,*c;
  100.  
  101. IntuitionBase = (struct IntuitionBase *)
  102.     OpenLibrary("intuition.library", INTUITION_REV);
  103. if( IntuitionBase == NULL )
  104.     cleanup("can't open intuition",1);
  105.  
  106. GfxBase = (struct GfxBase *)
  107.     OpenLibrary("graphics.library",GRAPHICS_REV);
  108. if( GfxBase == NULL )
  109.     cleanup("can't open graphics library",2);
  110.  
  111. if (p_screen == 1) {
  112.     if ((myscreen = (struct Screen *)OpenScreen(&NewScreen)) == NULL)
  113.     cleanup("can't open screen",3);
  114.     NewWindow.Screen = myscreen;
  115.     }
  116.  
  117. if ((mywindow = (struct Window *)OpenWindow(&NewWindow)) == NULL)
  118.     cleanup("can't open window",4);
  119. if ((myfont = (struct TextFont *)OpenFont(&myattr)) == NULL)
  120.     cleanup("can't open font",4);
  121.  
  122. myviewport   = (struct ViewPort *)ViewPortAddress(mywindow);
  123. myrastport   = (struct RastPort *)mywindow->RPort;
  124.  
  125. SetFont(myrastport,myfont);
  126.  
  127. if (p_depth > 1) myrequest.BackFill = 2;
  128. if (p_screen != 0 && p_wbcolors == 0) {
  129.     colors[0] = p_background;
  130.     colors[1] = p_foreground;
  131.     colors[2] = p_bold;
  132.     colors[3] = p_cursor;
  133.     if (p_depth == 1)
  134.     LoadRGB4(myviewport,(struct ColorMap *)colors,2L);
  135.     else
  136.         LoadRGB4(myviewport,(struct ColorMap *)colors,4L);
  137.     }
  138.  
  139. Read_Request = (struct IOExtSer *)
  140.     AllocMem((long)sizeof(*Read_Request),MEMF_PUBLIC|MEMF_CLEAR);
  141. Read_Request->io_SerFlags = 0L;
  142. Read_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  143. if(OpenDevice(SERIALNAME,NULL,Read_Request,NULL))
  144.     cleanup("Cant open Read device",5);
  145. rs_in = malloc(p_buffer+1);
  146. Read_Request->io_SerFlags = 0L;
  147. Read_Request->io_Baud      = p_baud;
  148. Read_Request->io_ReadLen  = 8L;
  149. Read_Request->io_WriteLen = 8L;
  150. Read_Request->io_CtlChar  = 0x11130000L;
  151. Read_Request->io_RBufLen  = p_buffer;
  152. Read_Request->io_BrkTime  = p_break;
  153. Read_Request->IOSer.io_Command = SDCMD_SETPARAMS;
  154. DoIO(Read_Request);
  155. Read_Request->IOSer.io_Command = CMD_READ;
  156. Read_Request->IOSer.io_Length  = 1;
  157. Read_Request->IOSer.io_Data    = (APTR) &rs_in[0];
  158.  
  159. Write_Request = (struct IOExtSer *)
  160.     AllocMem((long)sizeof(*Write_Request),MEMF_PUBLIC|MEMF_CLEAR);
  161. b = (BYTE *)Read_Request;
  162. c = (BYTE *)Write_Request;
  163. for (i=0;i<sizeof(struct IOExtSer);i++) *c++ = *b++;
  164. Write_Request->IOSer.io_Message.mn_ReplyPort = CreatePort(0L,0L);
  165. Write_Request->IOSer.io_Command = CMD_WRITE;
  166. Write_Request->IOSer.io_Length  = 1;
  167. Write_Request->IOSer.io_Data    = (APTR) &rs_out[0];
  168.  
  169. Timer_Port = CreatePort("Timer Port",0L);
  170. Script_Timer_Port = CreatePort("Timer Port",0L);
  171.  
  172. if (OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Timer, 0) ||
  173.     OpenDevice(TIMERNAME, UNIT_VBLANK, (char *) &Script_Timer, 0)) 
  174.     cleanup("can't open timer device",7);
  175.  
  176. Timer.tr_node.io_Message.mn_ReplyPort = Timer_Port;
  177. Timer.tr_node.io_Command = TR_ADDREQUEST;
  178. Timer.tr_node.io_Flags = 0;
  179. Timer.tr_node.io_Error = 0;
  180.  
  181. Script_Timer.tr_node.io_Message.mn_ReplyPort = Script_Timer_Port;
  182. Script_Timer.tr_node.io_Command = TR_ADDREQUEST;
  183. Script_Timer.tr_node.io_Flags = 0;
  184. Script_Timer.tr_node.io_Error = 0;
  185.  
  186. BeepWave   = (UBYTE *)AllocMem(BEEPSIZE,(long)(MEMF_CHIP|MEMF_CLEAR));
  187. if (BeepWave != 0) BeepWave[0] = 100;
  188.  
  189. Audio_Port = CreatePort("Audio Port",0L);
  190.  
  191. Audio_Request.ioa_Request.io_Message.mn_ReplyPort   = Audio_Port;
  192. Audio_Request.ioa_Request.io_Message.mn_Node.ln_Pri = 85;
  193. Audio_Request.ioa_Data            = Audio_AllocMap;
  194. Audio_Request.ioa_Length        = (ULONG) sizeof(Audio_AllocMap);
  195.  
  196. if (OpenDevice(AUDIONAME, NULL, (char *) &Audio_Request, NULL))
  197.     cleanup("can't open audio device",8);
  198.  
  199. Audio_Request.ioa_Request.io_Command    = CMD_WRITE;
  200. Audio_Request.ioa_Request.io_Flags    = ADIOF_PERVOL;
  201. Audio_Request.ioa_Data        = BeepWave;
  202. Audio_Request.ioa_Length    = BEEPSIZE;
  203. Audio_Request.ioa_Period    = COLORCLOCK / (BEEPSIZE * BEEPFREQ);
  204. Audio_Request.ioa_Volume    = p_volume;
  205. Audio_Request.ioa_Cycles    = 100;
  206. }
  207.  
  208. /*****************************************************************/
  209. /*    The following function initializes the structure arrays    */
  210. /*   needed to provide the File menu topic.                      */
  211. /*****************************************************************/
  212. void InitFileItems()
  213.     {
  214.     int        n,nplus1;
  215.  
  216. /* initialize each menu item and IntuiText with loop */
  217. for( n=0; n<FILEMAX; n++ )
  218.     {
  219.     nplus1 = n + 1;
  220.     FileItem[n].NextItem = &FileItem[nplus1];
  221.     FileItem[n].LeftEdge = 0;
  222.     FileItem[n].TopEdge = 10 * n;
  223.     FileItem[n].Width = 120+40;
  224.     FileItem[n].Height = 10;
  225.     FileItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  226.     FileItem[n].MutualExclude = 0;
  227.     FileItem[n].ItemFill = (APTR)&FileText[n];
  228.     FileItem[n].SelectFill = NULL;
  229.     if (n >= 2 && n <= 7) {
  230.     FileItem[n].Command  = cmds[n-2];
  231.     FileItem[n].Flags   |= COMMSEQ;
  232.     }
  233.     else FileItem[n].Command = 0;
  234.     FileItem[n].SubItem = NULL;
  235.     FileItem[n].NextSelect = 0;
  236.  
  237.     FileText[n].FrontPen = 0;
  238.     FileText[n].BackPen = 1;
  239.     FileText[n].DrawMode = JAM2;/* render in fore and background */
  240.     FileText[n].LeftEdge = 0;
  241.     FileText[n].TopEdge = 1;
  242.     FileText[n].ITextFont = NULL;
  243.     FileText[n].NextText = NULL;
  244.     }
  245. FileItem[FILEMAX-1].NextItem = NULL;
  246.  
  247. /* initialize text for specific menu items */
  248.  
  249. FileText[0].IText = (UBYTE *)"Ascii  Capture";
  250. FileText[1].IText = (UBYTE *)"Ascii  Send";
  251. FileText[2].IText = (UBYTE *)"Xmodem Receive";
  252. FileText[3].IText = (UBYTE *)"Xmodem Send";
  253. FileText[4].IText = (UBYTE *)"Kermit Get";
  254. FileText[5].IText = (UBYTE *)"Kermit Receive";
  255. FileText[6].IText = (UBYTE *)"Kermit Send";
  256. FileText[7].IText = (UBYTE *)"Kermit BYE";
  257. }
  258.  
  259. /******************************************************************
  260. /*            Main Comm menu
  261. /*        set up for Baud & Parity submenus
  262. /******************************************************************/
  263. void InitCommItems()
  264.     {
  265.     int        n,nplus1;
  266.  
  267. /* initialize each menu item and IntuiText with loop */
  268. for( n=0; n<COMMAX; n++ )
  269.     {
  270.     nplus1 = n + 1;
  271.     CommItem[n].NextItem = &CommItem[nplus1];
  272.     CommItem[n].LeftEdge = 0;
  273.     CommItem[n].TopEdge = 10 * n;
  274.     CommItem[n].Width = 88;
  275.     CommItem[n].Height = 10;
  276.     CommItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP ;
  277.     CommItem[n].MutualExclude = 0;
  278.     CommItem[n].ItemFill = (APTR)&CommText[n];
  279.     CommItem[n].SelectFill = NULL;
  280.     CommItem[n].Command = 0;
  281.     CommItem[n].NextSelect = 0;
  282.  
  283.     CommText[n].FrontPen = 0;
  284.     CommText[n].BackPen = 1;
  285.     CommText[n].DrawMode = JAM2;    
  286.     CommText[n].LeftEdge = 0;
  287.     CommText[n].TopEdge = 1;
  288.     CommText[n].ITextFont = NULL;
  289.     CommText[n].NextText = NULL;
  290.     }
  291. CommItem[COMMAX-1].NextItem = NULL;
  292.  
  293. CommText[0].IText = (UBYTE *)"Baud Rate";
  294. CommText[1].IText = (UBYTE *)"Parity   ";
  295. CommText[2].IText = (UBYTE *)"Xfer Mode";
  296. CommItem[0].SubItem = RSItem;
  297. CommItem[1].SubItem = ParItem;
  298. CommItem[2].SubItem = XFItem;
  299.  
  300. /*****************************************************************/
  301. /*    The following initializes the structure arrays         */
  302. /*   needed to provide the BaudRate Submenu topic.               */
  303. /*****************************************************************/
  304.  
  305. for( n=0; n<RSMAX; n++ )
  306.     {
  307.     nplus1 = n + 1;
  308.     RSItem[n].NextItem = &RSItem[nplus1];
  309.     RSItem[n].LeftEdge = 75;
  310.     RSItem[n].TopEdge = 10 * n;
  311.     RSItem[n].Width = 56+40;
  312.     RSItem[n].Height = 10;
  313.     RSItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  314.     RSItem[n].MutualExclude = (~(1 << n));
  315.     RSItem[n].ItemFill = (APTR)&RSText[n];
  316.     RSItem[n].SelectFill = NULL;
  317.     if (n >= 1 && n <= 2) {
  318.     RSItem[n].Command    = cmds[n+5];
  319.     RSItem[n].Flags        |= COMMSEQ;
  320.     }
  321.     else RSItem[n].Command = 0;
  322.     RSItem[n].SubItem = NULL;
  323.     RSItem[n].NextSelect = 0;
  324.  
  325.     RSText[n].FrontPen = 0;
  326.     RSText[n].BackPen = 1;
  327.     RSText[n].DrawMode = JAM2;     /* render in fore and background */
  328.     RSText[n].LeftEdge = 0;
  329.     RSText[n].TopEdge = 1;
  330.     RSText[n].ITextFont = NULL;
  331.     RSText[n].NextText = NULL;
  332.     }
  333. RSItem[RSMAX-1].NextItem = NULL;
  334.  
  335. /* select baud item chekced */
  336. switch (p_baud) {
  337.     case 300:    n = 0; break;
  338.     case 1200:    n = 1; break;
  339.     case 2400:    n = 2; break;
  340.     case 4800:    n = 3; break;
  341.     case 9600:    n = 4; break;
  342.     default:    n = 2; p_baud = 2400;
  343.     }
  344. RSItem[n].Flags |= CHECKED;
  345.  
  346. /* initialize text for specific menu items */
  347. RSText[0].IText = (UBYTE *)"   300";
  348. RSText[1].IText = (UBYTE *)"  1200";
  349. RSText[2].IText = (UBYTE *)"  2400";
  350. RSText[3].IText = (UBYTE *)"  4800";
  351. RSText[4].IText = (UBYTE *)"  9600";
  352.  
  353. /*****************************************************************/
  354. /*    The following initializes the structure arrays         */
  355. /*   needed to provide the Parity   Submenu topic.               */
  356. /*****************************************************************/
  357.  
  358. for( n=0; n<PARMAX; n++ )
  359.     {
  360.     nplus1 = n + 1;
  361.     ParItem[n].NextItem = &ParItem[nplus1];
  362.     ParItem[n].LeftEdge = 75;
  363.     ParItem[n].TopEdge = 10 * n;
  364.     ParItem[n].Width = 56+40;
  365.     ParItem[n].Height = 10;
  366.     ParItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  367.     ParItem[n].MutualExclude = (~(1 << n));
  368.     ParItem[n].ItemFill = (APTR)&ParText[n];
  369.     ParItem[n].SelectFill = NULL;
  370.     if (n == 0 || n == 3 || n == 4) {
  371.     ParItem[n].Command   = cmds[(n==0)?8:n+6];
  372.     ParItem[n].Flags    |= COMMSEQ;
  373.     }
  374.     else ParItem[n].Command = 0;
  375.     ParItem[n].SubItem = NULL;
  376.     ParItem[n].NextSelect = 0;
  377.  
  378.     ParText[n].FrontPen = 0;
  379.     ParText[n].BackPen = 1;
  380.     ParText[n].DrawMode = JAM2;/* render in fore and background */
  381.     ParText[n].LeftEdge = 0;
  382.     ParText[n].TopEdge = 1;
  383.     ParText[n].ITextFont = NULL;
  384.     ParText[n].NextText = NULL;
  385.     }
  386. ParItem[PARMAX-1].NextItem = NULL;
  387.  
  388. /* select parity item chekced */
  389. ParItem[p_parity].Flags |= CHECKED;
  390.  
  391. /* initialize text for specific menu items */
  392. ParText[0].IText = (UBYTE *)"  None ";
  393. ParText[1].IText = (UBYTE *)"  Mark ";
  394. ParText[2].IText = (UBYTE *)"  Space";
  395. ParText[3].IText = (UBYTE *)"  Even ";
  396. ParText[4].IText = (UBYTE *)"  Odd  ";
  397.  
  398. /*****************************************************************/
  399. /*    The following initializes the structure arrays         */
  400. /*    needed to provide the Transfer Mode menu topic.            */
  401. /*****************************************************************/
  402.  
  403. /* initialize each menu item and IntuiText with loop */
  404. for( n=0; n<XFMAX; n++ )
  405.     {
  406.     nplus1 = n + 1;
  407.     XFItem[n].NextItem = &XFItem[nplus1];
  408.     XFItem[n].LeftEdge = 75;
  409.     XFItem[n].TopEdge = 10 * n;
  410.     XFItem[n].Width = 80+40;
  411.     XFItem[n].Height = 10;
  412.     XFItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP | CHECKIT;
  413.     if (n < 2)  XFItem[n].MutualExclude = 2 - n;
  414.     else    XFItem[n].MutualExclude = 0;
  415.     XFItem[n].ItemFill = (APTR)&XFText[n];
  416.     XFItem[n].SelectFill = NULL;
  417.     if (n < 2) {
  418.     XFItem[n].Command    = cmds[n+11];
  419.     XFItem[n].Flags        |= COMMSEQ;
  420.     }
  421.     else XFItem[n].Command = 0;
  422.     XFItem[n].SubItem = NULL;
  423.     XFItem[n].NextSelect = 0;
  424.  
  425.     XFText[n].FrontPen = 0;
  426.     XFText[n].BackPen = 1;
  427.     XFText[n].DrawMode = JAM2;
  428.     XFText[n].LeftEdge = 0;
  429.     XFText[n].TopEdge = 1;
  430.     XFText[n].ITextFont = NULL;
  431.     XFText[n].NextText = NULL;
  432.     }
  433. XFItem[XFMAX-1].NextItem = NULL;
  434. /* mode checked */
  435. XFItem[p_mode].Flags |= CHECKED;
  436. if (p_convert)    XFItem[2].Flags |= CHECKED;
  437.  
  438. /* initialize text for specific menu items */
  439. XFText[0].IText = (UBYTE *)"  Image  ";
  440. XFText[1].IText = (UBYTE *)"  Text   ";
  441. XFText[2].IText = (UBYTE *)"  Convert";
  442.  
  443. } /* end of InitCommItems() */
  444.  
  445.  
  446. /*****************************************************************/
  447. /*    The following function initializes the structure arrays    */
  448. /*   needed to provide the Script menu topic.                    */
  449. /*****************************************************************/
  450. void InitScriptItems()
  451. {
  452. int n,nplus1;
  453.  
  454. /* initialize each menu item and IntuiText with loop */
  455. for( n=0; n<SCRIPTMAX; n++ )
  456.     {
  457.     nplus1 = n + 1;
  458.     ScriptItem[n].NextItem = &ScriptItem[nplus1];
  459.     ScriptItem[n].LeftEdge = 0;
  460.     ScriptItem[n].TopEdge = 10 * n;
  461.     ScriptItem[n].Width = 128;
  462.     ScriptItem[n].Height = 10;
  463.     ScriptItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  464.     ScriptItem[n].MutualExclude = 0;
  465.     ScriptItem[n].ItemFill = (APTR)&ScriptText[n];
  466.     ScriptItem[n].SelectFill = NULL;
  467.     ScriptItem[n].Command = 0;
  468.     ScriptItem[n].SubItem = NULL;
  469.     ScriptItem[n].NextSelect = 0;
  470.  
  471.     ScriptText[n].FrontPen = 0;
  472.     ScriptText[n].BackPen = 1;
  473.     ScriptText[n].DrawMode = JAM2;/* render in fore and background */
  474.     ScriptText[n].LeftEdge = 0;
  475.     ScriptText[n].TopEdge = 1;
  476.     ScriptText[n].ITextFont = NULL;
  477.     ScriptText[n].NextText = NULL;
  478.     }
  479. ScriptItem[SCRIPTMAX-1].NextItem = NULL;
  480.  
  481. /* initialize text for specific menu items */
  482. ScriptText[0].IText = (UBYTE *)"Execute file";
  483. ScriptText[1].IText = (UBYTE *)"Abort Execution";
  484. }
  485.  
  486. /*****************************************************************/
  487. /*    The following function initializes the structure arrays    */
  488. /*   needed to provide the Util menu topic.                    */
  489. /*****************************************************************/
  490. void InitUtilItems()
  491.     {
  492.     int        n,nplus1;
  493.  
  494. /* initialize each menu item and IntuiText with loop */
  495. for( n=0; n<UTILMAX; n++ )
  496.     {
  497.     nplus1 = n + 1;
  498.     UtilItem[n].NextItem = &UtilItem[nplus1];
  499.     UtilItem[n].LeftEdge = 0;
  500.     UtilItem[n].TopEdge = 10 * n;
  501.     UtilItem[n].Width = 88+40;
  502.     UtilItem[n].Height = 10;
  503.     UtilItem[n].Flags = ITEMTEXT | ITEMENABLED | HIGHCOMP;
  504.     if (n > 3) UtilItem[n].Flags |= CHECKIT;
  505.     UtilItem[n].MutualExclude = 0;
  506.     UtilItem[n].ItemFill = (APTR)&UtilText[n];
  507.     UtilItem[n].SelectFill = NULL;
  508.     if (n == 0 || n == 2) {
  509.     UtilItem[n].Command   = cmds[(n==0)?13:14];
  510.     UtilItem[n].Flags    |= COMMSEQ;
  511.     }
  512.     else if (n >= 5) {
  513.     UtilItem[n].Command   = cmds[n+10];
  514.     UtilItem[n].Flags    |= COMMSEQ;
  515.     }
  516.     else UtilItem[n].Command = 0;
  517.     UtilItem[n].SubItem = NULL;
  518.     UtilItem[n].NextSelect = 0;
  519.  
  520.     UtilText[n].FrontPen = 0;
  521.     UtilText[n].BackPen = 1;
  522.     UtilText[n].DrawMode = JAM2;/* render in fore and background */
  523.     UtilText[n].LeftEdge = 0;
  524.     UtilText[n].TopEdge = 1;
  525.     UtilText[n].ITextFont = NULL;
  526.     UtilText[n].NextText = NULL;
  527.     }
  528. UtilItem[UTILMAX-1].NextItem = NULL;
  529.  
  530. if (p_echo)        UtilItem[4].Flags |= CHECKED;
  531. if (p_wrap)        UtilItem[5].Flags |= CHECKED;
  532. if (p_keyapp == 0)  UtilItem[6].Flags |= CHECKED;
  533. if (p_curapp)        UtilItem[7].Flags |= CHECKED;
  534. if (p_bs_del)        UtilItem[8].Flags |= CHECKED;
  535.  
  536. /* initialize text for specific menu items */
  537. UtilText[0].IText = (UBYTE *)"Send Break";
  538. UtilText[1].IText = (UBYTE *)"Hang Up";
  539. UtilText[2].IText = (UBYTE *)"Change Dir";
  540. UtilText[3].IText = (UBYTE *)"Clear Scrn";
  541. UtilText[4].IText = (UBYTE *)"  Echo";
  542. UtilText[5].IText = (UBYTE *)"  Wrap";
  543. UtilText[6].IText = (UBYTE *)"  Num Key";
  544. UtilText[7].IText = (UBYTE *)"  App Cur";
  545. UtilText[8].IText = (UBYTE *)"  BS<->DEL";
  546. }
  547.  
  548. /****************************************************************/
  549. /*   The following function inits the Menu structure array with */
  550. /*  appropriate values for our simple menu.  Review the manual  */
  551. /*  if you need to know what each value means.                  */
  552. /****************************************************************/
  553. void InitMenu()
  554. {
  555. menu[0].NextMenu = &menu[1];
  556. menu[0].LeftEdge = 5;
  557. menu[0].TopEdge = 0;
  558. menu[0].Width = 40;
  559. menu[0].Height = 10;
  560. menu[0].Flags = MENUENABLED;
  561. menu[0].MenuName = "File";        /* text for menu-bar display */
  562. menu[0].FirstItem = &FileItem[0]; /* pointer to first item in list */
  563.  
  564. menu[1].NextMenu = &menu[2];
  565. menu[1].LeftEdge = 55;
  566. menu[1].TopEdge = 0;
  567. menu[1].Width = 88;
  568. menu[1].Height = 10;
  569. menu[1].Flags = MENUENABLED;
  570. menu[1].MenuName = "Comm Setup";   /* text for menu-bar display */
  571. menu[1].FirstItem = &CommItem[0];  /* pointer to first item in list */
  572.  
  573. menu[2].NextMenu = &menu[3];
  574. menu[2].LeftEdge = 153;
  575. menu[2].TopEdge = 0;
  576. menu[2].Width = 56;
  577. menu[2].Height = 10;
  578. menu[2].Flags = MENUENABLED;
  579. menu[2].MenuName = "Script";        /* text for menu-bar display */
  580. menu[2].FirstItem = &ScriptItem[0]; /* pointer to first item in list*/
  581.  
  582. menu[3].NextMenu = &menu[4];        /* link to tek menu items    */
  583. menu[3].LeftEdge = 225;
  584. menu[3].TopEdge = 0;
  585. menu[3].Width = 64;
  586. menu[3].Height = 10;
  587. menu[3].Flags = MENUENABLED;
  588. menu[3].MenuName = "Utility";      /* text for menu-bar display */
  589. menu[3].FirstItem = &UtilItem[0];  /* pointer to first item in list*/
  590. }
  591.  
  592.